<!DOCTYPE html>
<html class="x-admin-sm" lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>添加兼职信息</title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <link rel="stylesheet" th:href="@{/layui/css/font.css}">
    <link rel="stylesheet" th:href="@{/layui/css/xadmin.css}">
    <link rel="stylesheet" th:href="@{/layui/css/login.css}">
    <script charset="utf-8" th:src="@{/layui/lib/layui/layui.js}" type="text/javascript"></script>
    <script th:src="@{/layui/js/xadmin.js}" type="text/javascript"></script>
    <style>
        html, body {
            height: 100%;
            width: 100%;
        }
    </style>
</head>
<body class="login-bg">
<div class="layui-fluid">
    <div class="layui-row" style="width: 740px;margin: 20px auto auto;">
        <form class="layui-form" enctype="multipart/form-data" id="fm"
              style="padding: 30px 20px;background: white;border-radius: 20px">
            <div style="float: left;">

                <div class="layui-form-item" style="display: none">
                    <label class="layui-form-label" for="companyName">
                        <span class="x-red">*</span>公司名称&emsp;</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input" id="companyName" name="company.id" th:value="${id}" type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" for="jobName">招聘岗位&emsp;</label>
                    <div class="layui-input-inline">
                        <select id="jobName" lay-verify="required" name="job.id">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" for="cityName">工作地点&emsp;</label>
                    <div class="layui-input-inline">
                        <select id="cityName" lay-verify="required" name="city.id">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
            </div>

            <div style="float: left">
                <div class="layui-form-item">
                    <label class="layui-form-label" for="releaseTime">发布日期&emsp;</label>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input" id="releaseTime" name="releaseTime" type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" for="salary">薪资待遇&emsp;</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" id="salary" name="salary" type="text">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" for="hireNum">招聘人数&emsp;</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" id="hireNum" name="hireNum" type="text">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="message">招聘信息&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="message" name="message" style="width: 500px" type="text">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="workTimeStart">上班时间&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="workTimeStart" name="workTimeStart" type="text">
                </div>
                <label class="layui-form-label" for="workTimeEnd"
                       style="position: relative;bottom: 3px">下班时间&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="workTimeEnd" name="workTimeEnd" type="text">
                </div>
            </div>


            <label for="workDetails_notRea"></label><input class="layui-input titles" id="workDetails_notRea"
                                                           style="border: none"
                                                           th:value="工作详情" value="">
            <div class="layui-form-item">
                <label class="layui-form-label" for="duty_notRea">工作职责&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="duty_notRea" name="workDetail.duty" style="width: 500px" type="text">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="requestMessage_notRea">工作需求&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="requestMessage_notRea" name="workDetail.requestMessage"
                           style="width: 500px" type="text">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="joinMessage_notRea">加入须知&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="joinMessage_notRea" name="workDetail.joinMessage"
                           style="width: 500px" type="text">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="contact_notRea">联系方式&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="contact_notRea" name="workDetail.contact" style="width: 500px"
                           type="text">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="detailSalary_notRea">详情待遇&emsp;</label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="detailSalary_notRea" name="workDetail.salary" style="width: 500px"
                           type="text">
                </div>
            </div>

            <button class="layui-btn" id="L_repass" lay-filter="add" lay-submit
                    style="width: 100%" type="submit">添加信息
            </button>
        </form>
    </div>
</div>

<script>
    layui.use(['form', 'layer', 'laydate', 'jquery', 'upload'], function () {
        const form = layui.form, layer = layui.layer,
            laydate = layui.laydate, $ = layui.jquery;
        //时间选择器
        laydate.render({
            elem: '#releaseTime',
            type: 'datetime'
        });
        // 获取下拉框信息 (职业信息)
        $.get("/job_option_message", {}, function (data) {
            let list = data;
            const select = document.getElementById('jobName');
            if (list != null) {
                for (let c in list) {
                    let option = document.createElement("option");
                    option.setAttribute("value", list[c].id);
                    option.innerText = list[c].jobName;
                    select.appendChild(option)
                }
            }
            form.render('select');
        }, "json");
        // 获取下拉框信息 (市级信息)
        $.get("/city_option_message", {}, function (data) {
            let list = data;
            const select = document.getElementById('cityName');
            if (list != null) {
                for (let c in list) {
                    let option = document.createElement("option");
                    option.setAttribute("value", list[c].id);
                    option.innerText = list[c].cityName;
                    select.appendChild(option)
                }
            }
            form.render('select');
        }, "json");
        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data.field)
            $.ajax({
                url: "/company_add_pt_message_save_or_edit",
                method: 'post',
                data: data.field,
                dataType: 'JSON',
                success: function (res) {
                    if (res.code === 0) {
                        //弹出提示，并在1秒后进行跳转
                        layer.alert("增加成功", {
                            icon: 6
                        }, function () {
                            //关闭当前frame
                            xadmin.close();

                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                            return false;
                        });
                    } else {
                        layer.msg("新增失败:" + res.msg);
                        return false;
                    }
                }
            });
            return false;
        });
    })
</script>
</body>
</html>